package com.hexacta.hrs.services.person.impl;

import java.util.Collection;

import org.vectrics.user.Person;

import com.hexacta.hrs.repositories.PersonRepository;
import com.hexacta.hrs.repositories.RecordObjectRepository;
import com.hexacta.hrs.services.person.PersonService;

public class PersonServiceImpl implements PersonService {

    /** Un {@link RecordObjectRepository} de {@link Person}. */
    private PersonRepository personRepository;

    public void setPersonRepository(final PersonRepository personRepository) {
        this.personRepository = personRepository;
    }

    @Override
    public Collection<Person> getAllPerson() {
        return personRepository.all();
    }

    @Override
    public Person getPersonById(final long id) {
        return personRepository.forId(id);
    }

    @Override
    public Collection<Person> matching(final Person criteria) {
        return personRepository.matching(criteria);

    }

    public void save(final Person person) {
        personRepository.save(person);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.hexacta.hrs.services.person.PersonService#getPersonByEmail(java.lang
     * .String)
     */
    @Override
    public Person getPersonByEmail(final String email) {
        return personRepository.getByEmail(email);
    }
}
